<?php
    use User\Model\MemberServiceModel;
    use User\Model\MemberServiceItemModel;
?>
<!-- page heading start-->
<div class="page-heading">
    <h3>
        服务项目
    </h3>

</div>
<!-- page heading end-->
<div class="row">
    <div class="col-sm-12">
        <section class="panel">
            <header class="panel-heading">
                <a class="btn btn-default" href="/User/Member/itemAdd">增加</a>
                <a class="btn btn-default" href="/User/Member/index">会员列表</a>
                <a class="btn btn-default" href="/User/Member/memberClass">层级管理</a>
                <a class="btn btn-default" href="/User/Member/service">会员服务</a>
                <a class="btn btn-default" href="/User/Member/property">会员扩展信息</a>
                <a class="btn btn-default" href="/User/Member/item">服务项目</a>
            </header>
            <div class="panel-body">
                <table class="table table-hover general-table table-bordered">
                    <thead>
                    <tr>
                        <th width="12%">项目名称</th>
                        <th width="12%">所属服务</th>
                        <th width="6%">项目费用</th>
                        <th width="15%">项目描述</th>
                        <th width="10%">项目起始时间</th>
                        <th width="10%">项目结束时间</th>
                        <th width="10%">提醒</th>
                        <th width="10%">添加时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach($list as $val){?>
                    <tr>
                        <td>
                            <span>
                                <?php echo $val['name'];?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo MemberServiceModel::getNameById($val['service_id']);?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo $val['fee'];?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo $val['describe'];?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo $val['valid_start_date'];?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo $val['valid_end_date'];?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo MemberServiceItemModel::getRemind($val['is_remind']);?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo $val['added_time'];?>
                            </span>
                        </td>
                        <td>
                            <a class="btn btn-success"
                               href="<?php echo '/User/Member/itemUpdate?type=update&itemId=' . $val['item_id'];?>">编辑</a>
                            <a class="btn btn-info"
                               href="<?php echo '/User/Member/card?itemId=' . $val['item_id'];?>">卡片</a>
                            <br/><br/>
                            <a class="btn btn-default" href="#"
                               onclick="<?php echo 'return delete_data(' . $val['item_id'] .')';?>">删除</a>
                        </td>
                    </tr>
                    <?php }?>

                    </tbody>
                </table>
                <div class="pages">
                    {$page}
                </div>
            </div>
        </section>
    </div>
</div>
<script>
    function delete_data(id){
        $.ajax({
            data:{itemId:id},
            dataType:'json',
            url:'/User/Member/itemDelete',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
</script>